Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

140
Vistas
"&" and ">>" number operator in C++?

I am trying to make a raycaster game in Javascript, and to do so, I am following this tutorial, which is written in C++.

My problem stems from trying to convert the following two lines to javascript:

int tx = (int)(texWidth * (floorX - cellX)) & (texWidth - 1);
color = (color >> 1) & 8355711; // make a bit darker

I don't know what the "&" and ">>" mean in those two lines. Is there an equivalent in Javascript?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

>> is the right bit-shift operator and & is the bitwise-and operator, both of them are available in JavaScript

about 4 years ago · Juan Pablo Isaza Denunciar

0

The code directly translates to JS with the removal of the (int) typecast and the replacement of int with let/var/const.

let tx = (texWidth * (floorX - cellX)) & (texWidth - 1);    
color = (color >> 1) & 8355711; // make a bit darker 

& is the bitwise and, >> is the bitshift right, explained well here.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda